package com.example.easyexcel.dao;

import com.example.easyexcel.dto.AssetInterfaceApiInfo;
import com.example.easyexcel.dto.AssetInterfaceApiInfoDTO;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface AssetInterfaceApiInfoMapper {
    /**
     * 单条插入
     * @param entity 接口信息实体
     * @return 插入结果
     */
    int insert(AssetInterfaceApiInfo entity);

    /**
     * 批量插入
     * @param list 接口信息列表
     * @return 插入结果
     */
    int insertBatch(@Param("list") List<AssetInterfaceApiInfo> list);

    /**
     * 清空表数据
     */
    void truncateTable();

    /**
     * 查询需要迁移的接口API信息
     */
    @Results({
            @Result(property = "assetNo", column = "asset_no"),
            @Result(property = "interfaceName", column = "interface_name"),
            @Result(property = "createTime", column = "create_time"),
            @Result(property = "updateTime", column = "update_time"),
            @Result(property = "delFlag", column = "del_flag")
    })
    @Select("SELECT asset_no, interface_name, create_time, update_time, del_flag " +
            "FROM asset_interface_api_info " +
            "WHERE del_flag = 0 AND asset_no IS NOT NULL")
    List<AssetInterfaceApiInfoDTO> selectInterfaceApiInfoForMigration();
}

